import { reactive } from "vue";
import type { FormRules } from "element-plus";
import { isPhone, isEmail } from "@pureadmin/utils";

/** 自定义表单规则校验 */
// export const formRules = reactive(<FormRules>{
//   name: [{ required: true, message: "部门名称为必填项", trigger: "blur" }],
//   phone: [
//     {
//       validator: (rule, value, callback) => {
//         if (value === "") {
//           callback();
//         } else if (!isPhone(value)) {
//           callback(new Error("请输入正确的手机号码格式"));
//         } else {
//           callback();
//         }
//       },
//       trigger: "blur"
//       // trigger: "click" // 如果想在点击确定按钮时触发这个校验，trigger 设置成 click 即可
//     }
//   ],
//   email: [
//     {
//       validator: (rule, value, callback) => {
//         if (value === "") {
//           callback();
//         } else if (!isEmail(value)) {
//           callback(new Error("请输入正确的邮箱格式"));
//         } else {
//           callback();
//         }
//       },
//       trigger: "blur"
//     }
//   ]
// });
export const formRules = reactive(<FormRules>{
  user_id: [{ required: true, message: "采购用户为必填", trigger: "blur" }],
  limit_upper: [{ required: true, message: "每日接单上限为必填项", trigger: "blur" }],
  status: [{ required: true, message: "状态为必填项", trigger: "blur" }],

  deal_type: [{ required: true, message: "处理方式为必填项", trigger: "blur" }],
  tracking_no: [{ required: true, message: "跟踪单号为必填项", trigger: "blur" }],
  sales_expenses: [{ required: true, message: "售后费用为必填项", trigger: "blur" }],
  // is_urgent: [{ required: true, message: "是否加急为必填项", trigger: "blur" }],
});
export const formTiaojiaRules = reactive(<FormRules>{
  adjust_type: [{ required: true, message: "调价类型不能为空", trigger: "blur" }],
  change_type: [{ required: true, message: "调价方式不能为空", trigger: "blur" }],
  amount: [{ required: true, message: "调价金额不能为空", trigger: "blur"}],
  discount: [{ required: true, message: "调价折扣不能为空", trigger: "blur" }],
}); 